/**
 * https://leetcode.cn/problems/longest-substring-without-repeating-characters/submissions/
 * 03. 无重复字符的最长子串
 * medium, 陈贝纯 2024.07.15
 * 滑动窗口
 */


class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int mem[300]={0};
        int maxt=0;
        for(int i=0,j=0;j<s.size();++j){
            mem[s[j]]++;
            while(mem[s[j]]>1)
            mem[s[i++]]--;
            maxt=max(maxt,j-i+1);
        }
        return maxt;
    }
};
